﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using ASPNETPerformance.App_BusinessLogic.BasePages;
using ASPNETPerformance.App_BusinessLogic.Helpers;
using ASPNETPerformance.App_BusinessLogic.SEO;
using ASPNETPerformance.App_BusinessLogic.Utils;

namespace ASPNETPerformance._08_AjaxAndJson {
    public partial class LazyLoadImage : BasePage {
        protected void Page_Load( object sender, EventArgs e ) {

        }

        protected override void OnPreRender( EventArgs e ) {
            base.OnPreRender( e );
            SEOHelper.AddJavaScriptInclude( this, "~/_assets/js/jquery.lazyload.min.js" );

            SEOHelper.AddCustomCodeToHead( this,
                                          string.Format(
                                            @"<script type=""text/javascript"">
                                                jQuery(document).ready(function ($) {{
                                                    if (navigator.platform == ""iPad"") return;
                                                    $(""img"").lazyload({{
                                                        placeholder: ""{0}_assets/img/lazyload.gif"",
                                                        effect: ""fadeIn""
                                                    }});
                                                }});
                                            </script>", CommonHelper.RelativeWebRoot ) );
        }
    }
}